package sanbing.jcpplearning;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;

public class PooledByteBufExample {
    public static void main(String[] args) {
        // 创建一个池化分配器
        PooledByteBufAllocator allocator = PooledByteBufAllocator.DEFAULT;

        // 分配直接内存
        ByteBuf directBuffer = allocator.directBuffer(1024);
        System.out.println("Direct Buffer Capacity: " + directBuffer.capacity());

        // 分配堆内存
        ByteBuf heapBuffer = allocator.heapBuffer(1024);
        System.out.println("Heap Buffer Capacity: " + heapBuffer.capacity());

        // 释放内存
        directBuffer.release();
        heapBuffer.release();
    }
}